<?php
/**
 * @FileName:districtList.php
 * @Describe:TODO
 * @Author:Arthur
 * @Email:arthurkingtoo@foxmail.com
 * @Time:2012-8-18
 * @Version:V9.0
 */
 require_once(dirname(__FILE__)."/../config/config.php");
 $method = $_REQUEST['method'];
 if($method=='delete')
 {
 	$id = $_REQUEST['id'];
 	
 	$sqlparent = "select * from zy_businessarea where parentId=".$id;
 	$rs = mysql_query($sqlparent);
 	$sumrow = mysql_fetch_row($rs);
 	if($sumrow > 0)
 	{
 		echo "<script type='text/javascript'>alert('此选项有下级目录,不给予删除!'); return false;</script>";
 	}else
 	{
 		$sql="delete from zy_businessarea where id=".$id;
 		mysql_query($sql);
 		header("location:districtList.php");
 	}
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商圈管理页面</title>
</head>
<body>
<?php  
if($_SESSION['admin_name']=="")
{

	echo "<script>location.href='admin_login.php';</script>";
}
?>
<h1 align="center">商圈列表信息</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="900" height="25" align="center" border="1">
    <tr>
      <td width="173" height="25" align="center">序号</td>
      <td width="173" height="25" align="center">名称</td>
      <td width="354" height="25" colspan="3" align="center">操作</td>
    </tr>
    <?php 
    	$sql="select zy_businessarea.* from zy_businessarea where level=1";
    	$rs = mysql_query($sql);
    	while($result = mysql_fetch_array($rs)){
    ?>
     <tr>
	    <td align="center"><?php echo $result['id'];?></td>
	    <td ><?php echo $result['name']; ?></td>
	    <td align="center"><a href="area_managerment.php?method=inserto&level=2&id=<?php echo $result['id']; ?>">新增区域</a></td>
	    <td align="center"><a href="area_managerment.php?method=update&level=1&id=<?php echo $result['id']; ?>">修改</a></td>
	    <td align="center"><a href="districtList.php?method=delete&id=<?php echo $result['id']; ?>">删除</a></td>
	  </tr>
    <?php 
    	$sql1="select zy_businessarea.* from zy_businessarea where level=2 and parentId=".$result['id'];
    	$rs1 = mysql_query($sql1);
    	while($result1 = mysql_fetch_array($rs1)){
    ?>
	  <tr>
	    <td align="center"><?php echo $result1['id'];?></td>
	    <td ><?php
	    	  echo "--|".$result1['name'];
	     ?></td>
	     <td align="center"><a href="area_managerment.php?method=inserto&level=3&id=<?php echo $result1['id']; ?>">新增商圈</a></td>
	    <td align="center"><a href="area_managerment.php?method=update&level=2&id=<?php echo $result1['id']; ?>">修改</a></td>
	    <td align="center"><a href="districtList.php?method=delete&id=<?php echo $result1['id']; ?>">删除</a></td>
	  </tr>
	  <?php 
    	$sql2="select zy_businessarea.* from zy_businessarea where level=3 and parentId=".$result1['id'];
    	$rs2 = mysql_query($sql2);
    	while($result2 = mysql_fetch_array($rs2)){
    ?>
    <tr>
	    <td align="center"><?php echo $result2['id'];?></td>
	    <td ><?php
	    	  echo "--|--|".$result2['name'];
	     ?></td>
	    <td align="center"><a href="area_managerment.php?method=inserto&level=4&id=<?php echo $result2['id']; ?>">新增地址</a></td>
	    <td align="center"><a href="area_managerment.php?method=update&level=3&id=<?php echo $result2['id']; ?>">修改</a></td>
	    <td align="center"><a href="districtList.php?method=delete&id=<?php echo $result2['id']; ?>">删除</a></td>
	  </tr>
	  <?php 
    	$sql3="select zy_businessarea.* from zy_businessarea where level=4 and parentId=".$result2['id'];
    	$rs3 = mysql_query($sql3);
    	while($result3 = mysql_fetch_array($rs3)){
    ?>
    <tr>
	    <td align="center"><?php echo $result3['id'];?></td>
	    <td ><?php
	    	  echo "--|--|--|".$result3['name'];
	     ?></td>
	    <td align="center"><a href="shop_edit.php?id=<?php echo $result['id']; ?>">新增店铺</a></td>
	    <td align="center"><a href="area_managerment.php?method=update&level=4&id=<?php echo $result3['id']; ?>">修改</a></td>
	    <td align="center"><a href="districtList.php?method=delete&id=<?php echo $result3['id']; ?>">删除</a></td>
	  </tr>
  <?php }}}}?>
</table>
	<h3 align="center"><a href="admin_management.php">返回</a></h3>
</form>
</body>
</html>
